<div class="wrapper">
	<div class="books">
		<div class="search">
			<%= form_tag book_infos_path, :method => 'get' do %>
			  <p>
			    <%= text_field_tag :search, params[:search] %>
			    <%= submit_tag "", :class => 'searchButton' %>
			  </p>
			<% end %>
		</div>
		<table>
			<colgroup>
				<col class="column-odd">
				<col class="column-even">
				<col class="column-odd">
				<col class="column-even">
				<col class="column-odd">
				<col class="column-even">
				<col class="column-odd">
				<col class="column-even">
				<col class="column-odd">
				<col class="column-even">
				<col class="column-odd">
			</colgroup>
			<thead>
		  		<tr>
				    <th>ISBN</th>
				    <th><%= sortable "publishDate", "Publish Date" %></th>
				    <th>Publisher</th>
				    <th>Author</th>
				    <th><%= sortable "vote", "Vote" %></th>
				    <th>Number of vote</th>
				    <th>Name</th>
				    <th><%= sortable "category_id", "Category" %></th>
				    <th></th>
				    <% if session[:username_or_email] == 'admin' %>
					    <th></th>
					    <th></th>
					<% end %>
				</tr>
		    </thead>
		
			<tbody>
					<% @book_infos.each do |book_info| %>
			  		<tr>
					    <td><%= book_info.isbn %></td>
					    <td><%= book_info.publishDate.to_date %></td>
					    <td><%= book_info.publisher %></td>
					    <td><%= book_info.author %></td>
					    <td><%= book_info.vote %></td>
					    <td><%= book_info.numberOfVote %></td>
					    <td><%= book_info.name %></td>
					    <td><%= book_info.category.name %></td>
					    <td><%= link_to 'Show', book_info %></td>
					    <% if session[:username_or_email] == 'admin' %>
						    <td><%= link_to 'Edit', edit_book_info_path(book_info) %></td>
						    <td><%= link_to 'Destroy', book_info, method: :delete, data: { confirm: 'Are you sure?' } %></td>
			  			<% end %>
			  		</tr>
					<% end %>
			</tbody>
		</table>
	</div>
	<br />
	<% if session[:username_or_email] == 'admin' %>
		<%= link_to 'New Book info', new_book_info_path %>
	<% end %>
</div>
